<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>判断题</title>
</head>
<body>
<div class="easyui-layout" data-options="fit:true,border:false" >
  <div data-options="region:'west',title:'题类',split:true,hideCollapsedContent:false" style="width:240px;">
    <ul id="tree_judgment_questions20210421"></ul>
  </div>
  <div data-options="region:'center',border:true" >
    <table id="dg_judgment_questions20210421"></table>
  </div>
</div>

<div id="toolbar_dg_judgment_questions20210421">
  <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改</a>
  <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
</div>

<script>
  $(function (){
    $('#tree_judgment_questions20210421').tree({
      method:'get',
      url:'./../structure/queryTreeAll',
      animate: true,
      onClick: function(node){
        //判断点击的是叶节点
        if($(this).tree('isLeaf',node.target)){
          $('#dg_judgment_questions20210421').datagrid({
            url:'./../paperTwo/queryPaperTwoPid',
            queryParams: {
              pid: node.id,
              titleType:3
            }
          });
          return;
        }
      }
    });

    $('#dg_judgment_questions20210421').datagrid({
      method:'get',
      fit:true,
      fitColumns:true,
      border:false,
      singleSelect:true,
      nowrap:false,//设置为 true，则把数据显示在一行里。设置为 true 可提高加载性能。
      sortName:'id',
      sortOrder:'desc',
      columns:[[
        {field:'title',title:'题目',width:260},
        {field:'answer',title:'答案',width:40,
          formatter: function(value,row,index){
            if(value == '1'){
              return '正确';
            }
            return '错误';
          }
        },
        {field:'createTime',title:'创建时间',width:80,align:'center'},
        {field:'nanduxishu',title:'难易度',width:40,align:'center',
          formatter: function(value,row,index){
            if (value == 1){
              return '简单';
            }
            if (value == 2){
              return '中等';
            }
            if (value == 3){
              return '难';
            }
          }
        },
        {field:'status',title:'状态',width:40,align:'center',
          formatter: function(value,row,index){
            if(value == '1'){
              return '正常';
            }
            return '停用';
          }
        }
      ]],
      toolbar: '#toolbar_dg_judgment_questions20210421',
      pagination:true,
      rownumbers:true
    });
  })
</script>
</body>
</html>